package com.fouram.mybatis.service;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.function.Supplier;

/**
 * @description: 事务service,解决直接使用事务注解包括查询导致事务变大问题
 * @author: liupeng
 * @date: 2025/4/21
 */
@Service
public class TransactionService {

    @Transactional(rollbackFor = Exception.class)
    public <T> T execute(Supplier<T> supplier){
        return supplier.get();
    }
}
